<template>
    <ul class="suggest">
        <li class="title" v-show="suggests.length > 0">搜索"{{keywords}}"</li>
        <li v-for="item in suggests" :key="item.id" @click="$emit('searchResult',item.name)">
            <i></i>
            <span>{{item.name}}</span>
        </li>
    </ul>
</template>

<script>
export default {
    name: 'Suggest',
    props: {
        suggests: {
            type: Array,
            default() {
                return [];
            },
        },
        keywords: String
    },
    data() {
        return {

        }
    }
}
</script>

<style lang="less" scoped>
.suggest {                                                                                              
    li {
        display: flex;
        align-items: center;
        height: 45px;
        padding-left: 10px;
        span {
            position: relative;
            display: inline-block;
            flex: 1;
            width: 1%;
            padding-right: 10px;
            font-size: 15px;
            line-height: 45px;
            color: #333;
            text-align: left;
            &::after {
                content: "";
                position: absolute;
                left: 0;
                top: 0;
                z-index: 2;
                width: 200%;
                height: 200%;
                border-bottom: 1px solid rgba(0,0,0,.1);
                transform: scale(.5);
                transform-origin: top left;
            }
        }
        i {
            display: inline-block;
            width: 15px;
            height: 15px;
            background: url(../assets/search2.svg) no-repeat;
            background-size: contain;
            vertical-align: middle;
            margin-right: 7px;
        }
    }
    .title {
        position: relative;
        height: 50px;
        margin-left: 10px;
        padding-right: 10px;
        font-size: 15px;
        line-height: 50px;
        color: #507daf;
        padding-left: 0;
        &::after {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            z-index: 2;
            width: 200%;
            height: 200%;
            border-bottom: 1px solid rgba(0,0,0,.1);
            transform: scale(.5);
            transform-origin: top left;
        }
    }
}
</style>
